<template>
  <div class="menu">
    <a-button type="primary" style="margin-bottom: 16px" @click="toggleCollapsed">
      <a-icon :type="collapsed ? 'menu-unfold' : 'menu-fold'" />
    </a-button>
    <div class="title">title</div>
    <a-menu
      mode="inline"
      theme="dark"
      :inline-collapsed="collapsed"
    >
      <a-menu-item key="1">
        <!-- <a-icon type="pie-chart" /> -->
        <!-- <span> -->
          <router-link to="/home">首页</router-link>
        <!-- </span> -->
      </a-menu-item>

      <a-sub-menu key="sub1">
        <span slot="title"><a-icon type="mail" /><span>子菜单</span></span>
        <a-menu-item key="5">
          <router-link to="/about">关于</router-link>
        </a-menu-item>
      </a-sub-menu>

    </a-menu>
    <a-button @click="setVip">setVip-button</a-button>
    <a-button @click="post">post-button</a-button>
    <a-button @click="errGet">errGet-button</a-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      collapsed: false,
    };
  },
  created(){
    // this.getRight()
    this.getApi()
  },
  methods: {
    toggleCollapsed() {
      this.collapsed = !this.collapsed;
    },
    getRight(){
      this.$http.get("/admin/base/auth/menus/left").then(res => {
        console.log("res ==> ", res)
      }).catch(err => {
        console.log("err ==> ", err)
      })
    },
    getApi(){
      // agentId: 2799ba1400001d14
      // status: 0
      this.$http.get("/admin/sys/entrust/order/page", {
        params: {
          agentId: '2799ba1400001d14',
          status: 0
        }
      }).then(res => {
        console.log("getApi res ==> ", res)
      }).catch(err => {
        console.log("getApi err ==> ", err)
      })
    },
    setVip(){
      // /admin/sys/vip/ladder/update/post
      this.$http.put("/admin/sys/vip/ladder/update/post", {
        id: 1,
        name: 'SVIP',
        minAmount: 1000,
        maxAmount: 0
      }).then(res => {
        console.log("post res ==> ", res)
      }).catch(err => {
        console.log("post err ==> ", err)
      })
      // id: 1
      // name: SVIP
      // minAmount: 1000
      // maxAmount: 0
    },
    post(){
      // id: 27e7b53d00001d14
      // agentId: 2799ba1400001d14
      // /admin/sys/gxentrust/sell
      this.$http({
        method: "POST",
        url: "/admin/sys/gxentrust/sell",
        data: {
          id: '27e7b53d00001d14',
          agentId: '2799ba1400001d14'
        }
      }).then(res => {
        console.log("psot res ==> ", res)
      }).catch(err => {
        console.log("post err ==> ", err)
      })
    },
    errGet(){
      this.$http.get("/admin/sys/entrust/order/pagexxx").then(res => {
        console.log("errGet res ==> ", res)
      }).catch(err => {
        console.log("errGet err ==> ", err)
      })
    }
  },
};
</script>

<style lang="less" scoped>
.title{
  font-size: 20px;
  color: #fff;
}
.menu{
  background-color: #000c17;
}
</style>


